<!DOCTYPE html>





<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 3.9.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/favicon.ico?v=7.4.0">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon.ico?v=7.4.0">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon.ico?v=7.4.0">
  <link rel="mask-icon" href="/images/logo.svg?v=7.4.0" color="#222">

<link rel="stylesheet" href="/css/main.css?v=7.4.0">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css?v=4.7.0">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '7.4.0',
    exturl: false,
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false,"dimmer":false},
    copycode: {"enable":false,"show_result":false,"style":null},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    bookmark: {"enable":false,"color":"#222","save":"auto"},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: 'search.json',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    translation: {
      copy_button: '复制',
      copy_success: '复制成功',
      copy_failure: '复制失败'
    },
    sidebarPadding: 40
  };
</script>

  <meta name="description" content="0. 为什么内网穿透从公网中访问自己的私有设备向来是一件难事儿。 自己的主力台式机、NAS等等设备，它们可能处于路由器后，或者运营商因为IP地址短缺不给你分配公网IP地址。如果我们想直接访问到这些设备（远程桌面，远程文件，SSH等等），一般来说要通过一些转发或者P2P组网软件的帮助。">
<meta name="keywords" content="linux,frp">
<meta property="og:type" content="article">
<meta property="og:title" content="frp内网穿透的实践">
<meta property="og:url" content="https://unix2dos.github.io/p/cc6fa0e8.html">
<meta property="og:site_name" content="Levon&#39;s Blog">
<meta property="og:description" content="0. 为什么内网穿透从公网中访问自己的私有设备向来是一件难事儿。 自己的主力台式机、NAS等等设备，它们可能处于路由器后，或者运营商因为IP地址短缺不给你分配公网IP地址。如果我们想直接访问到这些设备（远程桌面，远程文件，SSH等等），一般来说要通过一些转发或者P2P组网软件的帮助。">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2020-04-25T05:07:19.416Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="frp内网穿透的实践">
<meta name="twitter:description" content="0. 为什么内网穿透从公网中访问自己的私有设备向来是一件难事儿。 自己的主力台式机、NAS等等设备，它们可能处于路由器后，或者运营商因为IP地址短缺不给你分配公网IP地址。如果我们想直接访问到这些设备（远程桌面，远程文件，SSH等等），一般来说要通过一些转发或者P2P组网软件的帮助。">
  <link rel="canonical" href="https://unix2dos.github.io/p/cc6fa0e8">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true,
    isPage: false,
    isArchive: false
  };
</script>

  <title>frp内网穿透的实践 | Levon's Blog</title>
  








  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">
  <div class="container use-motion">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-meta">

    <div>
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Levon's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
        <h1 class="site-subtitle" itemprop="description">微信:  L6241425</h1>
      
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
      
      
      
        
        <li class="menu-item menu-item-home">
      
    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-archives">
      
    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>时光</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-categories">
      
    

    <a href="/categories/" rel="section"><i class="menu-item-icon fa fa-fw fa-th"></i> <br>分类</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-tags">
      
    

    <a href="/tags/" rel="section"><i class="menu-item-icon fa fa-fw fa-tags"></i> <br>标签</a>

  </li>
      <li class="menu-item menu-item-search">
        <a href="javascript:;" class="popup-trigger">
        
          <i class="menu-item-icon fa fa-search fa-fw"></i> <br>搜索</a>
      </li>
    
  </ul>

</nav>
  <div class="site-search">
    <div class="popup search-popup">
    <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocorrect="off" autocapitalize="none"
           placeholder="搜索..." spellcheck="false"
           type="text" id="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result"></div>

</div>
<div class="search-pop-overlay"></div>

  </div>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
            

          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
      <article itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block post">
    <link itemprop="mainEntityOfPage" href="https://unix2dos.github.io/p/cc6fa0e8.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Levon">
      <meta itemprop="description" content="Never Give Up">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Levon's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">frp内网穿透的实践

          
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              
                
              

              <time title="创建时间：2019-12-13 21:11:46" itemprop="dateCreated datePublished" datetime="2019-12-13T21:11:46+08:00">2019-12-13</time>
            </span>
          
            

            
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-04-25 13:07:19" itemprop="dateModified" datetime="2020-04-25T13:07:19+08:00">2020-04-25</time>
              </span>
            
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/2-linux系统/" itemprop="url" rel="index"><span itemprop="name">2-linux系统</span></a></span>

                
                
                  ，
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/2-linux系统/系统/" itemprop="url" rel="index"><span itemprop="name">系统</span></a></span>

                
                
              
            </span>
          

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
        
      
      <span class="post-meta-item-text">Disqus：</span>
    
    <a title="disqus" href="/p/cc6fa0e8.html#comments" itemprop="discussionUrl"><span class="post-comments-count disqus-comment-count" data-disqus-identifier="p/cc6fa0e8.html" itemprop="commentCount"></span></a>
  </span>
  
  
          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
              
                <span class="post-meta-item-text">本文字数：</span>
              
              <span>3.6k</span>
            </span>
          
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
              
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              
              <span>3 分钟</span>
            </span>
          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h3 id="0-为什么内网穿透"><a href="#0-为什么内网穿透" class="headerlink" title="0. 为什么内网穿透"></a>0. 为什么内网穿透</h3><p>从公网中访问自己的私有设备向来是一件难事儿。</p>
<p>自己的主力台式机、NAS等等设备，它们可能处于路由器后，或者运营商因为IP地址短缺不给你分配公网IP地址。如果我们想直接访问到这些设备（远程桌面，远程文件，SSH等等），一般来说要通过一些转发或者P2P组网软件的帮助。</p>
<a id="more"></a>



<h3 id="1-安装配置-frp"><a href="#1-安装配置-frp" class="headerlink" title="1. 安装配置 frp"></a>1. 安装配置 frp</h3><p><a href="https://github.com/fatedier/frp/releases" target="_blank" rel="noopener">https://github.com/fatedier/frp/releases</a> 下载最新的release</p>
<h5 id="1-1服务端配置"><a href="#1-1服务端配置" class="headerlink" title="1.1服务端配置"></a>1.1服务端配置</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">sudo cp systemd/frps.service /lib/systemd/system/</span><br><span class="line"></span><br><span class="line"><span class="comment">#  /usr/bin/frps -c /etc/frp/frps.ini</span></span><br><span class="line"><span class="comment"># 我们按照 service 内的配置把文件拷贝到相应的地方</span></span><br><span class="line"></span><br><span class="line">sudo cp frps /usr/bin/frps</span><br><span class="line">sudo mkdir /etc/frp/</span><br><span class="line">sudo cp frps.ini /etc/frp/frps.ini</span><br><span class="line"></span><br><span class="line"><span class="comment"># 编辑frps.ini</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 开启 service</span></span><br><span class="line">sudo systemctl start frps</span><br><span class="line">sudo systemctl <span class="built_in">enable</span> frps</span><br></pre></td></tr></table></figure>

<h5 id="1-2-客户端"><a href="#1-2-客户端" class="headerlink" title="1.2 客户端"></a>1.2 客户端</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">sudo cp systemd/frpc.service /lib/systemd/system/</span><br><span class="line"></span><br><span class="line">sudo cp frpc /usr/bin/frpc</span><br><span class="line">sudo mkdir /etc/frp/</span><br><span class="line">sudo cp frpc.ini /etc/frp/frpc.ini</span><br><span class="line"></span><br><span class="line"><span class="comment">#编辑frpc.ini</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#1. 修改server_addr为服务端公网IP</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 开启 service</span></span><br><span class="line">sudo systemctl start frpc</span><br><span class="line">sudo systemctl <span class="built_in">enable</span> frpc</span><br></pre></td></tr></table></figure>

<h5 id="1-3-测试"><a href="#1-3-测试" class="headerlink" title="1.3 测试"></a>1.3 测试</h5><p>主题frpc里面有ssh配置, 所以我们通过 ssh 访问内网机器：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">ssh -p 6000 root@49.234.15.70</span><br><span class="line"></span><br><span class="line"><span class="comment"># 为了方便, 我们可以在~/.ssh/config 配置下面的话</span></span><br><span class="line"></span><br><span class="line">host box</span><br><span class="line">    Hostname 49.234.15.70</span><br><span class="line">    Port 6000</span><br><span class="line">    user root</span><br></pre></td></tr></table></figure>

<h3 id="2-自定义域名访问内网的-web-服务"><a href="#2-自定义域名访问内网的-web-服务" class="headerlink" title="2. 自定义域名访问内网的 web 服务"></a>2. 自定义域名访问内网的 web 服务</h3><p>有时想要让其他人通过域名访问或者测试我们在本地搭建的 web 服务，但是由于本地机器没有公网 IP，无法将域名解析到本地的机器，通过 frp 就可以实现这一功能，以下示例为 http 服务，https 服务配置方法相同， vhost_http_port 替换为 vhost_https_port， type 设置为 https 即可。</p>
<h5 id="2-1-修改-frps-ini"><a href="#2-1-修改-frps-ini" class="headerlink" title="2.1 修改 frps.ini"></a>2.1 修改 frps.ini</h5><p>设置 http 访问端口为 8080：</p>
<figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># frps.ini</span></span><br><span class="line"><span class="section">[common]</span></span><br><span class="line"><span class="attr">bind_port</span> = <span class="number">7000</span></span><br><span class="line"><span class="attr">vhost_http_port</span> = <span class="number">8080</span></span><br></pre></td></tr></table></figure>

<h5 id="2-2-启动-frps："><a href="#2-2-启动-frps：" class="headerlink" title="2.2 启动 frps："></a>2.2 启动 frps：</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl start frps</span><br></pre></td></tr></table></figure>

<h5 id="2-3-修改frpc-ini"><a href="#2-3-修改frpc-ini" class="headerlink" title="2.3 修改frpc.ini"></a>2.3 修改frpc.ini</h5><p>修改 frpc.ini 文件，假设 frps 所在的服务器的 IP 为 x.x.x.x，local_port 为本地机器上 web 服务对应的端口, 绑定自定义域名 <code>www.yourdomain.com</code>:</p>
<figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># frpc.ini</span></span><br><span class="line"><span class="section">[common]</span></span><br><span class="line"><span class="attr">server_addr</span> = x.x.x.x</span><br><span class="line"><span class="attr">server_port</span> = <span class="number">7000</span></span><br><span class="line"></span><br><span class="line"><span class="section">[web]</span></span><br><span class="line"><span class="attr">type</span> = http</span><br><span class="line"><span class="attr">local_port</span> = <span class="number">80</span></span><br><span class="line"><span class="attr">custom_domains</span> = www.yourdomain.com</span><br></pre></td></tr></table></figure>

<h5 id="2-4-启动-frpc："><a href="#2-4-启动-frpc：" class="headerlink" title="2.4 启动 frpc："></a>2.4 启动 frpc：</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl start frpc</span><br></pre></td></tr></table></figure>

<h5 id="2-5-绑定域名映射"><a href="#2-5-绑定域名映射" class="headerlink" title="2.5 绑定域名映射"></a>2.5 绑定域名映射</h5><p>将 <code>www.yourdomain.com</code> 的域名 A 记录解析到 IP <code>x.x.x.x</code>，如果服务器已经有对应的域名，也可以将 CNAME 记录解析到服务器原先的域名。</p>
<p>通过浏览器访问 <code>http://www.yourdomain.com:8080</code> 即可访问到处于内网机器上的 web 服务。</p>
<h3 id="3-frp-管理面板"><a href="#3-frp-管理面板" class="headerlink" title="3. frp 管理面板"></a>3. frp 管理面板</h3><p>服务端 frps 配置如下:</p>
<figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">[common]</span></span><br><span class="line"><span class="attr">bind_port</span> = <span class="number">7000</span></span><br><span class="line"><span class="attr">dashboard_port</span> = <span class="number">5000</span></span><br><span class="line"><span class="attr">dashboard_user</span> = admin</span><br><span class="line"><span class="attr">dashboard_pwd</span> = admin</span><br><span class="line"><span class="attr">vhost_http_port</span> = <span class="number">5001</span></span><br></pre></td></tr></table></figure>

<p>然后我们通过 ip:5000,即可以访问到 web 管理界面.</p>
<h3 id="4-nginx-反向代理进行无端口访问"><a href="#4-nginx-反向代理进行无端口访问" class="headerlink" title="4. nginx 反向代理进行无端口访问"></a>4. nginx 反向代理进行无端口访问</h3><h5 id="4-1-frp-相应配置"><a href="#4-1-frp-相应配置" class="headerlink" title="4.1 frp 相应配置"></a>4.1 frp 相应配置</h5><ul>
<li><p>frps</p>
<figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">[common]</span></span><br><span class="line"><span class="attr">bind_port</span> = <span class="number">7000</span></span><br><span class="line"><span class="attr">dashboard_port</span> = <span class="number">5000</span></span><br><span class="line"><span class="attr">dashboard_user</span> = admin</span><br><span class="line"><span class="attr">dashboard_pwd</span> = admin</span><br><span class="line"><span class="attr">vhost_http_port</span> = <span class="number">5001</span></span><br></pre></td></tr></table></figure>



</li>
</ul>
<ul>
<li><p>frpc</p>
<figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">[web]</span></span><br><span class="line"><span class="attr">type</span> = http</span><br><span class="line"><span class="attr">local_port</span> = <span class="number">80</span></span><br><span class="line"><span class="attr">custom_domains</span> = box.frp.liuvv.com</span><br></pre></td></tr></table></figure>

</li>
</ul>
<h5 id="4-2-在服务端架设-nginx"><a href="#4-2-在服务端架设-nginx" class="headerlink" title="4.2 在服务端架设 nginx"></a>4.2 在服务端架设 nginx</h5><p>1、 frp.liuvv.com 做A记录，解析至IP；</p>
<p>2、 *.frp.liuvv.com 做CNAME记录，解析至 frp.liuvv.com;</p>
<p>3、 配置nginx反向代理,将来自*.frp.liuvv.com的80端口请求，分发至frp服务器http请求的监听端口。</p>
<figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">server</span> &#123;</span><br><span class="line"></span><br><span class="line">    <span class="attribute">listen</span> <span class="number">80</span>;</span><br><span class="line"></span><br><span class="line">    <span class="attribute">server_name</span> frp.liuvv.com;</span><br><span class="line"></span><br><span class="line">    <span class="attribute">location</span> / &#123;</span><br><span class="line"></span><br><span class="line">        <span class="attribute">proxy_pass</span> http://127.0.0.1:5000;<span class="comment"># dashboard</span></span><br><span class="line"></span><br><span class="line">        <span class="attribute">proxy_set_header</span>    Host            <span class="variable">$host</span>:<span class="number">80</span>;</span><br><span class="line"></span><br><span class="line">        <span class="attribute">proxy_set_header</span>    X-Real-IP       <span class="variable">$remote_addr</span>;</span><br><span class="line"></span><br><span class="line">        <span class="attribute">proxy_set_header</span>    X-Forwarded-For <span class="variable">$proxy_add_x_forwarded_for</span>;</span><br><span class="line"></span><br><span class="line">        <span class="attribute">proxy_hide_header</span>   X-Powered-By;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="section">server</span> &#123;</span><br><span class="line"></span><br><span class="line">    <span class="attribute">listen</span> <span class="number">80</span>;</span><br><span class="line"></span><br><span class="line">    <span class="attribute">server_name</span> <span class="regexp">*.frp.liuvv.com</span>;</span><br><span class="line"></span><br><span class="line">    <span class="attribute">access_log</span> /var/log/nginx/frp_access.log;</span><br><span class="line"></span><br><span class="line">    <span class="attribute">error_log</span> /var/log/nginx/frp_error.log;</span><br><span class="line"></span><br><span class="line">    <span class="attribute">location</span> / &#123;</span><br><span class="line"></span><br><span class="line">        <span class="attribute">proxy_pass</span> http://127.0.0.1:5001;<span class="comment"># vhost_http</span></span><br><span class="line"></span><br><span class="line">        <span class="attribute">proxy_set_header</span>    Host            <span class="variable">$host</span>:<span class="number">80</span>;</span><br><span class="line"></span><br><span class="line">        <span class="attribute">proxy_set_header</span>    X-Real-IP       <span class="variable">$remote_addr</span>;</span><br><span class="line"></span><br><span class="line">        <span class="attribute">proxy_set_header</span>    X-Forwarded-For <span class="variable">$proxy_add_x_forwarded_for</span>;</span><br><span class="line"></span><br><span class="line">        <span class="attribute">proxy_hide_header</span>   X-Powered-By;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="5-远程桌面连接局域网mac"><a href="#5-远程桌面连接局域网mac" class="headerlink" title="5.  远程桌面连接局域网mac"></a>5.  远程桌面连接局域网mac</h3><p>mac去下载darwin_amd64,  然后启动客户端 frpc</p>
<h5 id="5-1-开启屏幕共享"><a href="#5-1-开启屏幕共享" class="headerlink" title="5.1  开启屏幕共享"></a>5.1  开启屏幕共享</h5><p>在系统设置-&gt;共享-&gt;开启屏幕共享</p>
<p>即开启了 vnc 服务</p>
<h5 id="5-2-修改frpc配置"><a href="#5-2-修改frpc配置" class="headerlink" title="5.2 修改frpc配置"></a>5.2 修改frpc配置</h5><figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">[common]</span> </span><br><span class="line"><span class="attr">server_addr</span> = <span class="number">49.234</span>.<span class="number">15.70</span></span><br><span class="line"><span class="attr">server_port</span> = <span class="number">7000</span></span><br><span class="line"></span><br><span class="line"><span class="section">[vnc]</span> </span><br><span class="line"><span class="attr">type</span> = tcp </span><br><span class="line"><span class="attr">local_ip</span> = <span class="number">127.0</span>.<span class="number">0.1</span> </span><br><span class="line"><span class="attr">local_port</span> = <span class="number">5900</span> </span><br><span class="line"><span class="attr">remote_port</span> = <span class="number">35900</span> </span><br><span class="line"><span class="attr">use_encryption</span> = <span class="literal">true</span> </span><br><span class="line"><span class="attr">use_compression</span> = <span class="literal">true</span></span><br></pre></td></tr></table></figure>

<h5 id="5-3-连接远程"><a href="#5-3-连接远程" class="headerlink" title="5.3 连接远程"></a>5.3 连接远程</h5><p>在 finder, cmd+k, 进行连接</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vnc://49.234.15.70:35900</span><br></pre></td></tr></table></figure>

<h3 id="6-参考资料"><a href="#6-参考资料" class="headerlink" title="6. 参考资料:"></a>6. 参考资料:</h3><ul>
<li><p><a href="https://github.com/fatedier/frp/blob/master/README_zh.md" target="_blank" rel="noopener">https://github.com/fatedier/frp/blob/master/README_zh.md</a></p>
</li>
<li><p><a href="https://www.iyuu.cn/archives/286/" target="_blank" rel="noopener">https://www.iyuu.cn/archives/286/</a></p>
</li>
<li><p><a href="http://yuqiangcoder.com/2019/11/22/frp-内网穿透-实现MAC远程桌面.html" target="_blank" rel="noopener">实现MAC远程桌面</a></p>
</li>
</ul>

    </div>

    
    
    
        
      
        <div id="reward-container">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作, 一个耿直的笑脸~</div>
  <button id="reward-button" disable="enable" onclick="var qr = document.getElementById(&quot;qr&quot;); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
        
      
      <div style="display: inline-block">
        <img src="/images/wechatpay.jpg" alt="Levon 微信支付">
        <p>微信支付</p>
      </div>
        
      
      <div style="display: inline-block">
        <img src="/images/alipay.jpg" alt="Levon 支付宝">
        <p>支付宝</p>
      </div>

  </div>
</div>

      

      <footer class="post-footer">
          
            
          
          <div class="post-tags">
            
              <a href="/tags/linux/" rel="tag"># linux</a>
            
              <a href="/tags/frp/" rel="tag"># frp</a>
            
          </div>
        

        

          <div class="post-nav">
            <div class="post-nav-next post-nav-item">
              
                <a href="/p/2e33702e.html" rel="next" title="数据库范式和函数依赖">
                  <i class="fa fa-chevron-left"></i> 数据库范式和函数依赖
                </a>
              
            </div>

            <span class="post-nav-divider"></span>

            <div class="post-nav-prev post-nav-item">
              
                <a href="/p/890e8359.html" rel="prev" title="k8s的初探">
                  k8s的初探 <i class="fa fa-chevron-right"></i>
                </a>
              
            </div>
          </div>
        
      </footer>
    
  </div>
  
  
  
  </article>

  </div>


          </div>
          
    
    
  <div class="comments" id="comments">
    <div id="disqus_thread">
      <noscript>Please enable JavaScript to view the comments powered by Disqus.</noscript>
    </div>
  </div>
  
  

        </div>
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">
        
        
        
        
      

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#0-为什么内网穿透"><span class="nav-number">1.</span> <span class="nav-text">0. 为什么内网穿透</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-安装配置-frp"><span class="nav-number">2.</span> <span class="nav-text">1. 安装配置 frp</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#1-1服务端配置"><span class="nav-number">2.0.1.</span> <span class="nav-text">1.1服务端配置</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#1-2-客户端"><span class="nav-number">2.0.2.</span> <span class="nav-text">1.2 客户端</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#1-3-测试"><span class="nav-number">2.0.3.</span> <span class="nav-text">1.3 测试</span></a></li></ol></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-自定义域名访问内网的-web-服务"><span class="nav-number">3.</span> <span class="nav-text">2. 自定义域名访问内网的 web 服务</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#2-1-修改-frps-ini"><span class="nav-number">3.0.1.</span> <span class="nav-text">2.1 修改 frps.ini</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#2-2-启动-frps："><span class="nav-number">3.0.2.</span> <span class="nav-text">2.2 启动 frps：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#2-3-修改frpc-ini"><span class="nav-number">3.0.3.</span> <span class="nav-text">2.3 修改frpc.ini</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#2-4-启动-frpc："><span class="nav-number">3.0.4.</span> <span class="nav-text">2.4 启动 frpc：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#2-5-绑定域名映射"><span class="nav-number">3.0.5.</span> <span class="nav-text">2.5 绑定域名映射</span></a></li></ol></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-frp-管理面板"><span class="nav-number">4.</span> <span class="nav-text">3. frp 管理面板</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-nginx-反向代理进行无端口访问"><span class="nav-number">5.</span> <span class="nav-text">4. nginx 反向代理进行无端口访问</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#4-1-frp-相应配置"><span class="nav-number">5.0.1.</span> <span class="nav-text">4.1 frp 相应配置</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#4-2-在服务端架设-nginx"><span class="nav-number">5.0.2.</span> <span class="nav-text">4.2 在服务端架设 nginx</span></a></li></ol></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-远程桌面连接局域网mac"><span class="nav-number">6.</span> <span class="nav-text">5.  远程桌面连接局域网mac</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#5-1-开启屏幕共享"><span class="nav-number">6.0.1.</span> <span class="nav-text">5.1  开启屏幕共享</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#5-2-修改frpc配置"><span class="nav-number">6.0.2.</span> <span class="nav-text">5.2 修改frpc配置</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#5-3-连接远程"><span class="nav-number">6.0.3.</span> <span class="nav-text">5.3 连接远程</span></a></li></ol></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-参考资料"><span class="nav-number">7.</span> <span class="nav-text">6. 参考资料:</span></a></li></ol></div>
        
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image"
      src="/images/avatar.jpg"
      alt="Levon">
  <p class="site-author-name" itemprop="name">Levon</p>
  <div class="site-description" itemprop="description">Never Give Up</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        
          <a href="/archives/">
        
          <span class="site-state-item-count">127</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-categories">
        
          
            <a href="/categories/">
          
        
        <span class="site-state-item-count">34</span>
        <span class="site-state-item-name">分类</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-tags">
        
          
            <a href="/tags/">
          
        
        <span class="site-state-item-count">76</span>
        <span class="site-state-item-name">标签</span>
        </a>
      </div>
    
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://github.com/unix2dos" title="GitHub &rarr; https://github.com/unix2dos" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="mailto:levonfly@gmail.com" title="E-Mail &rarr; mailto:levonfly@gmail.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://twitter.com/levonfly" title="Twitter &rarr; https://twitter.com/levonfly" rel="noopener" target="_blank"><i class="fa fa-fw fa-twitter"></i>Twitter</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://weibo.com/l6241425" title="Weibo &rarr; https://weibo.com/l6241425" rel="noopener" target="_blank"><i class="fa fa-fw fa-weibo"></i>Weibo</a>
      </span>
    
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Levon</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    <span title="站点总字数">507k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">7:41</span>
</div>

        












        
      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js?v=3.1.0"></script>
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
<script src="/js/utils.js?v=7.4.0"></script><script src="/js/motion.js?v=7.4.0"></script>
<script src="/js/schemes/pisces.js?v=7.4.0"></script>

<script src="/js/next-boot.js?v=7.4.0"></script>



  
  <script>
    (function(){
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      bp.src = (curProtocol === 'https') ? 'https://zz.bdstatic.com/linksubmit/push.js' : 'http://push.zhanzhang.baidu.com/push.js';
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
    })();
  </script>








  <script src="/js/local-search.js?v=7.4.0"></script>














  

  

  

<script>
  function loadCount() {
    var d = document, s = d.createElement('script');
    s.src = 'https://levonfly.disqus.com/count.js';
    s.id = 'dsq-count-scr';
    (d.head || d.body).appendChild(s);
  }
  // defer loading until the whole page loading is completed
  window.addEventListener('load', loadCount, false);
</script>
<script>
  function disqus_config() {
    this.page.url = "https://unix2dos.github.io/p/cc6fa0e8.html";
    this.page.identifier = "p/cc6fa0e8.html";
    this.page.title = 'frp内网穿透的实践';};
  function loadComments() {
    if (window.DISQUS) {
      DISQUS.reset({
        reload: true,
        config: disqus_config
      });
    } else {
      var d = document, s = d.createElement('script');
      s.src = 'https://levonfly.disqus.com/embed.js';
      s.setAttribute('data-timestamp', '' + +new Date());
      (d.head || d.body).appendChild(s);
    }
  }
    window.addEventListener('load', loadComments, false);
  
</script>

</body>
</html>
